package by.bucha.testproject.response;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import android.content.res.Resources.NotFoundException;
import by.bucha.testproject.xml.XmlParser;
import by.bucha.testproject.xml.bo.ResultModel;
import by.bucha.testproject.xml.handlers.ResultHandler;

public class XmlResultModelResponse extends CommonAsyncTask<ResultModel> {

	public XmlResultModelResponse(CallbackAsyncTask<ResultModel> paramCallback) {
		super(paramCallback);
	}

	@Override
	protected ResultModel convertResult(String string) throws Exception {

		ResultModel result = null;
		try {
			ResultHandler xmlHandler = new ResultHandler();
			XmlParser.getInstance().parse(string, xmlHandler);
			result = xmlHandler.getResult();
		} catch (NotFoundException e) {
			e.printStackTrace();
		} catch (SAXException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
		}

		return result;
	}
}
